{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5050\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "\n",
    "for x in range(1, 101):\n",
    "    total += x\n",
    "else:\n",
    "    print(total)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for x in range(5):\n",
    "    print(x)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for x in range(1, 10):\n",
    "    print(x)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for x in range(1, 10, 2):\n",
    "    print(x)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "finish\n",
      "5050\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "\n",
    "for x in range(1, 101):\n",
    "    total += x\n",
    "    if x > 50:\n",
    "        break\n",
    "else:\n",
    "    print(\"finish\")\n",
    "\n",
    "print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "finish\n",
      "2500\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "\n",
    "for x in range(1, 101):\n",
    "    if x % 2 == 0:\n",
    "        continue\n",
    "\n",
    "    total += x\n",
    "else:\n",
    "    print(\"finish\")\n",
    "\n",
    "print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "finish\n",
      "2550\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "\n",
    "for x in range(1, 101):\n",
    "    if x % 2 != 0:\n",
    "        continue\n",
    "\n",
    "    total += x\n",
    "else:\n",
    "    print(\"finish\")\n",
    "\n",
    "print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5050\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "n = 1\n",
    "\n",
    "while n <= 100:\n",
    "    total += n\n",
    "    n += 1\n",
    "else:\n",
    "    print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2500\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "n = 1\n",
    "\n",
    "while n <= 100:\n",
    "    total += n\n",
    "    n += 2\n",
    "else:\n",
    "    print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2550\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "n = 2\n",
    "\n",
    "while n <= 100:\n",
    "    total += n\n",
    "    n += 2\n",
    "else:\n",
    "    print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1275\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "n = 1\n",
    "\n",
    "while n <= 100:\n",
    "    total += n\n",
    "    n += 1\n",
    "\n",
    "    if n > 50:\n",
    "        break\n",
    "else:\n",
    "    print(\"finish\")\n",
    "\n",
    "print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2550\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "n = 1\n",
    "\n",
    "while n <= 100:\n",
    "    if n % 2 == 1:\n",
    "        n += 1\n",
    "        continue\n",
    "\n",
    "    total += n\n",
    "    n += 1\n",
    "else:\n",
    "    print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2500\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "n = 1\n",
    "\n",
    "while n <= 100:\n",
    "    if n % 2 == 0:\n",
    "        n += 1\n",
    "        continue\n",
    "\n",
    "    total += n\n",
    "    n += 1\n",
    "else:\n",
    "    print(total)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}